close all;
clc;

%upscaling scale change between Y and X
scale_change = 4;
%standard deviation of the Gaussian kernel
sigma_filter= 1;
%window size of the Gaussian kernel
filter_size= 5;

%Ytrue: original HR image
Ytrue = imread('mandrill_lumi.bmp');
%gaussian filter
filter = fspecial('gaussian', filter_size, sigma_filter);

% obtaining a LR version of Ytrue
X = imfilter(Ytrue,filter,'symmetric','same');
X = imresize(X, 1/scale_change, 'bicubic');

% create a first guess of the HR image
Y = imresize(X, scale_change, 'bicubic');

figure;
subplot(1,3,1);
imshow(Ytrue);
title('Image HR originale');

subplot(1,3,2);
imshow(X);
title('Image LR calculee');

subplot(1,3,3);
imshow(Y);
title('Interpolation bicubic');

psnr(Ytrue,Y)

%other way to get the psnr:
%[psnr,mse,maxerr,l2rat] = measerr(Ytrue,Y);
%psnr
